<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%-- JSTL表达式（判断，循环，输出） --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%-- 方法表达式（字符串截取，替换） --%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<div class="add-dress">

	<!--标题 -->
	<div class="am-cf am-padding">
		<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong></div>
	</div>
	<hr/>

	<div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
		<form class="am-form am-form-horizontal" style="padding: 15px;" id="expressForm">
			<input type="hidden" name="expressId" value="${expressInfo.expressId}" />
			<div class="am-form-group">
				<label for="user-name" class="am-form-label">收货人</label>
				<div class="am-form-content">
					<input class="input_style" type="text" id="user-name" name="name" placeholder="收货人" value="${expressInfo.name}">
				</div>
			</div>

			<div class="am-form-group">
				<label for="user-phone" class="am-form-label">手机号码</label>
				<div class="am-form-content">
					<input class="input_style" id="user-phone" name="mobile" placeholder="手机号必填" type="email" value="${expressInfo.mobile}">
				</div>
			</div>
			<div class="am-form-group">
				<label class="am-form-label">所在地</label>
				<div class="am-form-content address">
					<%--<select data-am-selected>
                        <option value="a">浙江省</option>
                        <option value="b" selected>湖北省</option>
                    </select>
                    <select data-am-selected>
                        <option value="a">温州市</option>
                        <option value="b" selected>武汉市</option>
                    </select>
                    <select data-am-selected>
                        <option value="a">瑞安区</option>
                        <option value="b" selected>洪山区</option>
                    </select>--%>
					<select name="province" class="input-ld">
						<option value="">请选择省</option>
					</select>
					<select name="city" class="input-ld">
						<option value="">请选择市</option>
					</select>
					<select name="district" class="input-ld">
						<option value="">请选择区</option>
					</select>
					<input type="hidden" id="areaId" name="areaId" />
				</div>
			</div>

			<div class="am-form-group">
				<label for="user-intro" class="am-form-label">详细地址</label>
				<div class="am-form-content">
					<textarea class="input_style" rows="3" name="address" id="user-intro" placeholder="输入详细地址">${expressInfo.address}</textarea>
				</div>
			</div>

			<div class="am-form-group">
				<div class="am-u-sm-9 am-u-sm-push-3">
					<a href="javascript:;" class="am-btn am-btn-danger" id="saveAddress">保存</a>
					<a href="javascript: void(0)" class="am-close am-btn am-btn-danger" <%--data-am-modal-close--%> onclick="window.location.reload();">取消</a>
				</div>
			</div>
		</form>
	</div>

</div>
<script>
	$(function () {
		$(".input-ld").ld({ajaxOptions : {"url" : "<%=basePath%>area/getAreaListByParentId"},defaultParentId :'root',texts : <c:if test="${defaultValList!=null}">${defaultValList}</c:if><c:if test="${defaultValList==null}">[]</c:if>});

		var lock = false;
		$("#saveAddress").click(function () {
			getAreaId($("#expressForm"), $("#areaId"));
			if(!check()) return;
			if(lock) return;
			lock = true;
			$.post("<%=basePath%>user/newExpress", $("#expressForm").serialize(), function (res) {
				if(res.code == 1){
					window.location.reload();
				}else{
					alert(res.message);
					lock = false;
				}
			});
		});
	});
</script>